package com.pingtai.ajax.action;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.http.Header;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.params.ConnRoutePNames;
import org.apache.http.message.BasicNameValuePair;

import com.pingtai.util.ChangeCharset;
import com.pingtai.util.HttpClientUtils;
import com.pingtai.util.Utils;

public class proxyTest {

	public static void main(String[] args) throws Exception {
		HttpClient client = null;
		client = HttpClientUtils.getHttpClient();
		HttpHost proxy = new HttpHost("218.11.74.193",18186); 
		client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);  
		Date date = new Date();
		String s = "1转发微博";
    	HttpPost postMeth = new HttpPost("http://weibo.com/aj/mblog/forward?_wv=5&__rnd="+date.getTime());
    	List<NameValuePair> nvps = new ArrayList<NameValuePair>();  
        nvps.add(new BasicNameValuePair("mid", "3655778449955685"));  
        nvps.add(new BasicNameValuePair("style_type", "2"));  
        nvps.add(new BasicNameValuePair("reason", s)); 
        nvps.add(new BasicNameValuePair("location", "page_100505_single_weibo"));  
        nvps.add(new BasicNameValuePair("pdetail", "1005053253407992")); 
        nvps.add(new BasicNameValuePair("_t", "0"));
    	postMeth.addHeader("Accept-Language", "zh-cn");
    	postMeth.addHeader("Accept-Encoding", "deflate");
        postMeth.addHeader("Accept","*/*");
        postMeth.addHeader("Accept-Charset","utf-8,GBK;q=0.7,*;q=0.3");
        postMeth.addHeader("Connection","keep-alive");
        postMeth.setHeader("Content-Type","application/x-www-form-urlencoded;charset=gb2312");
        postMeth.addHeader("Cookie","SINAGLOBAL=4881056891754.27.1378798357905; myuid=3518116565; SUB=AWod8zfwno9Cjdbt3Dq9ElkCfVaZfzKqbUnCFEjZoxb6Whz7gHE2kPW3wQxM3ZSxTFeoQ5JwtiEzCVMqxFbRquylbmlKBlMygF8P6r2%2BIveG; un=mjjsojava@163.com; UV5PAGE=usr513_135; SUE=es%3D2ee82f76601e33205726c5eeabc8d1f5%26ev%3Dv1%26es2%3D0f77522ce15e3cd2a2aa7754f939170e%26rs0%3D2IEVXBWVMyad9KBlQNqsiwDIaSI68pyeVne%252FCvVog9%252FvxW08J%252FLAK%252BeoBw%252Fyo4WpF4N0Yu5eMcaSVKpDRd4JzJTnqHwigvdepcufZZG7DYCDw5LwFCXm4Ifixa03qRtpmdWLJaXvn0OkDJ9jwIx6VGQV1fj2n55X40%252Bc7q64TCE%253D%26rv%3D0; SUP=cv%3D1%26bt%3D1387099660%26et%3D1387186060%26d%3Dc909%26i%3Dc718%26us%3D1%26vf%3D0%26vt%3D0%26ac%3D0%26st%3D0%26uid%3D2046055133%26name%3Dmjjsojava%2540163.com%26nick%3Dmjjsojava%26fmp%3D%26lcp%3D2013-10-25%252008%253A58%253A47; SUS=SID-2046055133-1387099660-XD-oei8b-e8bd8f1f5ec2e5c37ae22a8ede2b2bf4; ALF=1389691659; SSOLoginState=1387099660; UUG=usr431_27; _s_tentry=login.sina.com.cn; UOR=itbbs.pconline.com.cn,widget.weibo.com,login.sina.com.cn; Apache=837152542080.7302.1387099607575; ULV=1387099607636:43:7:1:837152542080.7302.1387099607575:1386910870983; UV5=usr319_193; wvr=5");
        postMeth.addHeader("Host","weibo.com");
        postMeth.addHeader("Origin","http://weibo.com");
        postMeth.addHeader("Referer","http://weibo.com/1975894555/AiR3hbqsY?mod=weibotime&type=repost");
        postMeth.addHeader("User-Agent","Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1 QIHU 360SE");
        postMeth.addHeader("X-Requested-With","XMLHttpRequest");
        postMeth.setEntity(new UrlEncodedFormEntity(nvps,"UTF-8"));  
        HttpResponse response = client.execute(postMeth);
		InputStream in = response.getEntity().getContent();
		String msg = Utils.InputStreamTOString(in, "utf-8");
    	msg = ChangeCharset.fromEncodedUnicode(msg.toCharArray(), 0, msg.length());
		System.out.println(msg);

	    }
}
